package com.campus.customer.controller;

import com.campus.common.bean.common.Resp;
import com.campus.customer.service.GoodsService;
import com.campus.customer.vo.GoodsVo;
import com.campus.customer.vo.OrderGoodsVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author ZhaoYuJie
 * @since 2025-04-02
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @ApiOperation("根据商户ID查询商品列表")
    @GetMapping("/list")
    public Resp<List<GoodsVo>> list(@ApiParam(value = "商户ID", required = true) @RequestParam("merchantId") Integer merchantId) {
        return Resp.success(goodsService.listWithSpecifications(merchantId));
    }

    @ApiOperation("根据订单ID查询商品列表")
    @GetMapping("/listByOrderId")
    public Resp<List<OrderGoodsVo>> listByOrderId(@ApiParam(value = "订单ID", required = true) @RequestParam("orderId") String orderId) {
        return Resp.success(goodsService.listByOrderId(orderId));
    }

}
